/**
 * 
 */
package demo.web.controller;


import com.github.pagehelper.PageInfo;
import demo.model.Notice;
import demo.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**  
 * 类描述：  ssss
 */
@Controller
public class TeacherNoticeController {
	

	@Autowired
	private NoticeService noticeService;
	
	/**
	 * 
	* @Title: getNoticeById 
	* @Description: 根据id查询公告内容
	*@return  
	* Notice
	 */
	@RequestMapping(value = "/getNoticeById", method = RequestMethod.POST)
	@ResponseBody
	public Object getNoticeById(Integer id) {
		return noticeService.selectByPrimaryKey(id);
	}

	/**
	 * 
	* @Title: getList 
	* @Description: 查询所有公告
	*@return  
	* List<Notice>
	 */
	@GetMapping(value="/list")
	public String getList(Integer pageIndex, Model model) {
		if(pageIndex==null) {
			pageIndex=1;
		}
		PageInfo<Notice> pageInfo=noticeService.getAllNotice(pageIndex, 5);
		model.addAttribute("list",pageInfo.getList());
		return "list";
	}

}
